file(STRINGS "${cpprealm_SOURCE_DIR}/dependencies.list" DEPENDENCIES)
message("Dependencies: ${DEPENDENCIES}")
foreach(LINE IN LISTS DEPENDENCIES)
    string(REGEX MATCHALL "([^=]+)" KEY_VALUE ${LINE})
    list(GET KEY_VALUE 0 KEY)
    list(GET KEY_VALUE 1 VALUE)
    set(DEP_${KEY} ${VALUE})
endforeach()

#check version format
string(REGEX MATCH "^[0-9]+\.[0-9]+\.[0-9]+$" CONFIG_REALMCXX_VERSION ${DEP_VERSION})
if (NOT CONFIG_REALMCXX_VERSION)
    string(REGEX MATCH "^[0-9]+\.[0-9]+\.[0-9]+-.+$" CONFIG_REALMCXX_VERSION ${DEP_VERSION})
    if (NOT CONFIG_REALMCXX_VERSION)
        message(FATAL_ERROR "Wrong version number format: ${DEP_VERSION}.")
    endif()
    set(extended_version 1)
endif()

# Split "x.y.z-t" into a list x;y;z;t
string(REGEX MATCHALL "[^.-]+" VERSION_LIST ${CONFIG_REALMCXX_VERSION})
list(GET VERSION_LIST 0 CONFIG_REALMCXX_VERSION_MAJOR)
list(GET VERSION_LIST 1 CONFIG_REALMCXX_VERSION_MINOR)
list(GET VERSION_LIST 2 CONFIG_REALMCXX_VERSION_PATCH)
if (extended_version)
    list(GET VERSION_LIST 3 CONFIG_REALMCXX_VERSION_TWEAK)
endif()